<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    
</body>
</html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="author" content="qinianqing">
    <title></title>
    <style>

    </style>
</head>

<body>

</body>

<ml>
<script>
    function number() {
        var xitong = Math.ceil(Math.random() * 100);
        console.log(xitong);
        for (i = 3; i > 0; i--) {
            var num = prompt("请输入你预测的数值", "请输入1-100的值");
            if (num == xitong) {
                alert("恭喜你，猜中了")
                break;
            }
             else if ((i - 1) != 0) {
                if (num < xitong) {
                    alert("您猜的数字小了，您还有" + (i - 1) + "次机会");
                }
                 else {
                    alert("您猜的数字大了，您还有" + (i - 1) + "次机会");
                }
            } 
            else {
                alert("游戏结束")
                break;
            }
        }
    }
    number();

    

</script>
